from dataclasses import dataclass
from enum import Enum
from typing import List


class Type(str, Enum):
    """Vulnerability scan type enumeration."""

    PACKAGE_LIST = 'packagelist'
    FULL_SCAN = 'fullscan'


@dataclass
class Agent:
    """Agent data model."""

    id: str = None


@dataclass
class Package:
    """Package data model."""

    architecture: str
    checksum: str
    description: str
    format: str
    groups: str
    item_id: str
    multiarch: str
    name: str
    priority: str
    scan_time: str
    size: int
    source: str
    vendor: str
    version: str


@dataclass
class OS:
    """Operating system data model."""

    architecture: str = None
    checksum: str = None
    hostname: str = None
    codename: str = None
    major_version: str = None
    minor_version: str = None
    name: str = None
    patch: str = None
    platform: str = None
    version: str = None
    scan_time: str = None
    kernel_release: str = None
    kernel_name: str = None
    kernel_version: str = None


@dataclass
class ScanRequest:
    """Scan request data model."""

    type: Type
    packages: List[Package]
    agent: Agent = None
    hotfixes: List[str] = None
    os: OS = None


@dataclass
class Vector:
    """CVSS v3.0 vector data model."""

    attack_vector: str
    availability: str
    confidentiality_impact: str
    integrity_impact: str
    privileges_required: str
    scope: str
    user_interaction: str


@dataclass
class CVSSV3:
    """CVSS v3.0 vector data model."""

    vector: Vector


@dataclass
class CVSS:
    """CVSS score data model."""

    cssv3: CVSSV3


@dataclass
class Score:
    """Vulnerability score data model."""

    base: int
    version: str


@dataclass
class Vulnerability:
    """Vulnerability data model."""

    assigner: str
    category: str
    classification: str
    condition: str
    cvss: CVSS
    cwe_reference: str
    description: str
    detected_at: str
    enumeration: str
    id: str
    item_id: str
    published_at: str
    reference: str
    score: Score
    severity: str
    updated: str


@dataclass
class ScanResponse:
    """Scan response data model."""

    vulnerabilities: List[Vulnerability]
